home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-06-15 | 3.9 KB | 193 lines | [TEXT/MPS ] |
- /*-----------------------------------------------------------------------------
-
- Generic LaserWriter.c
-
- This part of the driver demonstrates how to force the PostScript
- imaging system to copy its output to a file.
-
- 12/18/93 - dmh - Removed IIg-dependencies for b3.
- 9/13/93 - dmh - Updated for the b2 seed.
- 9/14/93 - dmh - Disabled the PostScript log which was created in
- the Extensions folder.
- 3/22/94 - dmh - Balanced gxInitialize override with a gxShutDown one.
- 6/14/94 - dmh - Added the mystical, magical, 30 second alert.
- 8/28/94 - dmh - Finalized for SDK.
- 6/14/96 - cn - Updated to support Universal Interfaces 2.1.
-
- © 1991-1996 Apple Computer Inc.
-
- -----------------------------------------------------------------------------*/
-
- // If non-zero, we create a PostScript log in the Extensions folder.
-
- #define CREATELOG 0
-
- #include <GXPrinterDrivers.h>
- #include <GXExceptions.h>
-
- #define kCreatorType 'scL2'
- #define kMyStatID gxPrintingDriverBaseID
-
-
- extern long A5Size (void);
- extern void A5Init (void *);
-
-
- // Globals...
-
- short gLogRefNum;
-
-
- OSErr DriverPostScriptDoPageSetup( gxFormat theFormat,
- long pageindx,
- gxPostScriptImageDataHdl imageDataHdl )
- {
- OSErr status;
- char *setupcommand = (char *) "\p%% File For Level-I or Level-II.\n";
-
- require(CREATELOG, Not_Logging);
- status = Send_GXBufferData( & setupcommand[ 1 ], setupcommand[ 0 ], 0 );
- nrequire( status, BufferCommandFailed );
-
- Not_Logging:
-
- status = Forward_GXPostScriptDoPageSetup( theFormat, pageindx, imageDataHdl );
- ncheck( status );
-
- BufferCommandFailed:
- return( status );
- }
-
-
- OSErr Do30SecondAlert()
- {
- OSErr anErr;
- gxStatusRecord *pStatus;
- long numTicks;
-
- // allocate the status record
-
- pStatus = (gxStatusRecord *) NewPtrClear(sizeof(gxStatusRecord));
- anErr = MemError();
-
- if (anErr == noErr ) {
- pStatus->statusOwner = kCreatorType;
- pStatus->statResId = kMyStatID;
- pStatus->statResIndex = 1;
- pStatus->bufferLen = 0;
-
-
- // Tell the Printing Manager to display the 30 second alert
-
- numTicks = TickCount();
-
- do
- {
- anErr = GXAlertTheUser(pStatus);
-
- // wait for 30 seconds.
-
- if ((anErr == noErr) && (pStatus->dialogResult == 0)) {
-
- Boolean weBeDone;
-
- weBeDone = (TickCount() - numTicks) >= 30*60;
-
- if (weBeDone) {
- pStatus->statResIndex = 2;
- anErr = GXAlertTheUser(pStatus);
- pStatus->dialogResult = ok;
-
- }
- }
-
- } while ((pStatus->dialogResult == 0) && (anErr == noErr));
-
- DisposePtr((Ptr) pStatus);
- }
- return( anErr );
- }
-
-
- OSErr DriverOpenConnection(void)
- {
- OSErr status;
-
- Do30SecondAlert();
- status = Forward_GXOpenConnection();
- nrequire(status, failed_Forward);
- require(CREATELOG, Not_Logging);
-
- status = Create("\pPostScriptLog.ps", 0, 'MPS ', 'TEXT');
- ncheck(status);
- status = FSOpen("\pPostScriptLog.ps", 0, &gLogRefNum);
- ncheck(status);
-
- status = noErr;
-
- Not_Logging:
- failed_Forward:
- return(status);
-
- }//DriverOpenConnection
-
-
- OSErr DriverCloseConnection(void)
- {
- OSErr status;
- long j;
-
- status = Forward_GXCloseConnection();
- nrequire(status, failed_Forward);
- require(CREATELOG, Not_Logging);
-
- GetFPos(gLogRefNum, &j);
- SetEOF(gLogRefNum, j);
- FSClose(gLogRefNum);
-
- Not_Logging:
- failed_Forward:
- return(status);
- }
-
-
-
- OSErr DriverInitialize(void)
- {
- OSErr status;
-
- status = NewMessageGlobals(A5Size(), A5Init);
- nrequire(status, failed_a5);
-
- failed_a5:
- return(status);
-
- }
-
-
- OSErr DriverShutDown(void)
- {
- DisposeMessageGlobals();
- return noErr;
- }
-
-
- OSErr DriverDumpBuffer(gxPrintingBuffer *buffPtr)
- {
- OSErr status;
- long count;
-
- require(CREATELOG, Not_Logging);
- count = buffPtr->size;
-
- status = FSWrite(gLogRefNum, &count, buffPtr->data);
- nrequire(status, failed_Write);
-
- Not_Logging:
- status = Forward_GXDumpBuffer(buffPtr);
- ncheck(status);
-
- failed_Write:
- return(status);
-
- }